home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
blankery
/
blitzblank
/
sources
/
bb.aquarium
< prev
next >
Wrap
Text File
|
1993-09-17
|
6KB
|
305 lines
CloseEd
NEWTYPE.spritedata
a.w
b
c
d
e
f
End NEWTYPE
NEWTYPE.tags
a.l
b
c
d
e
f
End NEWTYPE
DEFTYPE.spritedata *sprdata
DEFTYPE.Screen *myscreen,*myscreen2
DEFTYPE.NewScreen newscreen
DEFTYPE.Window *mywindow
DEFTYPE.NewWindow newwindow
DEFTYPE.Message *msg
DEFTYPE.MsgPort *port
DEFTYPE.tags tags
DEFTYPE.l
Statement stringborder{x,y,w,h}
Wline x+1,y+h+2,x+1,y,x+w+8,y,1
Wline x+w+10,y-1,x+w+10,y+h+4,x-1,y+h+4,1
Wline x,y+h+3,x,y,1
Wline x+w+11,y-1,x+w+11,y+h+4,1
Wline x-1,y+h+3,x-1,y-1,x+w+10,y-1,2
Wline x+w+9,y,x+w+9,y+h+3,x+1,y+h+3,2
Wline x-2,y+h+4,x-2,y-1,2
Wline x+w+8,y+1,x+w+8,y+h+2,2
End Statement
Select Par$(1)
Case "BLANK"
name$="BB.BlankModule"+Chr$(0)
*port=CreateMsgPort_()
*port\mp_Node\ln_Name=&name$
*port\mp_Node\ln_Pri=1
AddPort_ *port
SetTaskPri_ FindTask_(0),Val(Par$(8))
fish=1
Gosub readconfig
*sprdata=AllocMem_(SizeOf.spritedata,#MEMF_CHIP|#MEMF_CLEAR)
newwindow\LeftEdge=0,0,1,1
newwindow\Flags=#WFLG_ACTIVATE
newwindow\FirstGadget=0,0,0,0,0,-1,-1,-1,-1,#WBENCHSCREEN
*mywindow=OpenWindow_(newwindow)
SetPointer_ *mywindow,*sprdata,0,0,0,0
width=Val(Par$(2))+280
height=Val(Par$(3))
mode=Val(Par$(4))
monitor=Val(Par$(5))
depth=3
title$="BB.Aquarium0"+Chr$(0)
newscreen\LeftEdge=-140,0,width+4,height,3
newscreen\ViewModes=0,#CUSTOMSCREEN|#SCREENBEHIND,0,&title$
tags\a=#SA_DisplayID
tags\b=$10000*monitor+mode
tags\c=0
*myscreen=OpenScreenTagList_(newscreen,tags)
title2$="BB.Aquarium1"+Chr$(0)
newscreen\ViewModes=0,#CUSTOMSCREEN|#SCREENBEHIND,0,&title2$
*myscreen2=OpenScreenTagList_(newscreen,tags)
shapes=19
mh=4
If height<300
mh/2
EndIf
If *myscreen<>0 AND *myscreen2<>0
LoadShapes 1,shapes,path$+"BB.Aquarium.data"
LoadShape 10,path$+"BB.Aquarium.pal",0
For i=1 To shapes
If height<300
Scale i,1,0.5,0
EndIf
MidHandle i
CopyShape i,20+i
XFlip 20+i
MidHandle 20+i
Next i
Handle 10,0,0
For i=0 To 1
FindScreen i,"BB.Aquarium"+Str$(i)
ScreensBitMap i,i
Use Palette 0
Boxf 0,0,width-1,height-1,0
Next i
Use BitMap 0
Dim x.q(fish+1)
Dim y.q(fish+1)
Dim r.q(fish+1)
Dim s(fish+1)
Dim ya.q(fish+1)
Dim dy.q(fish+1)
Queue 0,fish+1
Queue 1,fish+1
Repeat
UnQueue sc
For i=1 To fish
If r(i)=0
If 1 ;Rnd(50)<1
s(i)=Rnd(shapes-10)+1
r(i)=Int(Rnd(2))
If r(i)=0
r(i)=-1
x(i)=width-70
Else
x(i)=70
EndIf
y(i)=Rnd(height-ShapeHeight(s(i))-4-mh)+ShapeHeight(s(i))/2+mh
r(i)*(Rnd(1)+0.5)
ya(i)=y(i)
dy(i)=r(i)/3
EndIf
Else
ya(i)+dy(i)
If ya(i)>y(i)+mh OR ya(i)<y(i)-mh
If s(i)<10
s(i)+10
Else
s(i)-10
EndIf
dy(i)=-dy(i)
ya(i)+2*dy(i)
EndIf
x(i)+r(i)
If r(i)<0
If x(i)>70
QBlit sc,s(i),x(i)+0.5,ya(i)+0.5
Else
r(i)=0
EndIf
Else
If x(i)<width-70
QBlit sc,20+s(i),x(i)+0.5,ya(i)+0.5
Else
r(i)=0
EndIf
EndIf
EndIf
Next i
If yb=0
yb=height-ShapeHeight(10)
xb=Rnd(width/2)+width/4
Else
yb-1
QBlit sc,10,xb,yb
EndIf
ShowScreen sc
sc=1-sc
Use BitMap sc
*msg=GetMsg_(*port)
Until *msg
EndIf
CloseScreen_ *myscreen
CloseScreen_ *myscreen2
ClearPointer_ *mywindow
CloseWindow_ *mywindow
FreeMem_ *sprdata,SizeOf.spritedata
RemPort_ *port
DeleteMsgPort_ *port
Case "INFO"
title$="Aquarium"+Chr$(0)
reqtext$="Aquarium - Module for BlitzBlank"+Chr$(10)
reqtext$+Chr$(169)+" 1993 by Thomas Brkel"+Chr$(10)
reqtext$+"Graphics by Michael Weber"+Chr$(10)+Chr$(10)
reqtext$+"Fishes are swimming on a 8-color-screen"+Chr$(10)
reqtext$+"with doublebuffering. Much CHIP-RAM needed."+Chr$(10)
reqtext$+"Aquarium is not compatible with graphic-cards."+Chr$(10)+Chr$(10)
reqtext$+"Choose the number of fishes in the config-window."+Chr$(0)
gadget$="OK"+Chr$(0)
easy.EasyStruct\es_StructSize=SizeOf.EasyStruct
easy\es_Title=&title$
easy\es_TextFormat=&reqtext$
easy\es_GadgetFormat=&gadget$
EasyRequestArgs_ 0,easy,0,0
Case "CONFIG"
*myscreen=LockPubScreen_(0)
width=*myscreen\Width
height=*myscreen\Height
font=*myscreen\Font\ta_YSize
Gosub readconfig
WbToScreen 0
BorderPens 0,0
StringGadget 0,100,25,0,0,3,30
Window 0,width/2-90,height/2-25,180,50,$100e,"Aquarium",1,2,0
stringborder{100,25,30,8}
WColour 2
WLocate 40,24-font
Print "Fish:"
WLocate 40,24-font+8
Print "(1-10)"
SetString 0,0,Str$(fish)
ActivateString 0,0
Repeat
ev=WaitEvent
Until ev=$200 OR ev=$40
fish=Val(StringText$(0,0))
Free Window 0
Gosub writeconfig
UnlockPubScreen_ 0,*myscreen
End Select
End
.readconfig
path$=Par$(9)
For i=10 To NumPars
path$=path$+" "+Par$(i)
Next i
If ReadFile(0,path$+"BB.Modules.config")
FileInput 0
While NOT Eof(0)
If Edit$(100)="*** Aquarium ***"
fish=Edit(5)
EndIf
Wend
DefaultInput
CloseFile 0
EndIf
Gosub checkval
Return
.writeconfig
Gosub checkval
If ReadFile(0,path$+"BB.Modules.config")
If WriteFile(1,path$+"BB.Modules.temp")
FileInput 0
FileOutput 1
While NOT Eof(0)
f$=Edit$(100)
If f$="*** Aquarium ***"
Repeat
f2$=Edit$(100)
Until Eof(0) OR Left$(f2$,3)="***"
If NOT Eof(0) Then NPrint f2$
Else
NPrint f$
EndIf
Wend
CloseFile 1
EndIf
CloseFile 0
EndIf
KillFile path$+"BB.Modules.config"
f$=path$+"BB.Modules.temp"+Chr$(0)
f2$=path$+"BB.Modules.config"+Chr$(0)
Rename_ &f$,&f2$
If OpenFile(0,path$+"BB.Modules.config")
FileOutput 0
FileSeek 0,Lof(0)
NPrint "*** Aquarium ***"
NPrint fish
CloseFile 0
EndIf
Return
.checkval
If fish<1 Then fish=3
If fish>10 Then fish=3
Return